import arcpy
from stormwaterutilities import addMessage
from polylinerasterintersect import PolylineRasterIntersect
from accumulatetonetwork import AccumulateToNetwork

#primary input features
#NOTE - these must be synced therefore updates should be for all 4 inputs at the same time
conveyance = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DrainageReserve.gdb2\StormDrainConveyance"
nodes = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DrainageReserve.gdb2\StormDrainNodes"
catchments = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DrainageReserve2.gdb\InletCatchmentsDetailed"
flowdir = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\flowdir_tau.tif"

pzone = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DR_inputs.gdb\pzone_raster"
czone = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DR_inputs.gdb\czone_raster"
ms4 = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DR_inputs.gdb\ms4_ofbounds_raster"
ImpA = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DR_inputs.gdb\ImpA_raster"
ROW_accum = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\ROW_tau.tif"
ROW = r"\\ws18325\Stormwater D\RiskModel\RiskAssessment\ConveyanceRoute\DR_inputs.gdb\ROW_raster"

#intersect stormlines with raster to append raster values
addMessage("*** Populating polylines with pzone from raster ***")
PolylineRasterIntersect(conveyance, pzone, "Value", "pzone")

#intersect stormlines with raster to append raster values
addMessage("*** Populating polylines with czone from raster ***")
PolylineRasterIntersect(conveyance, czone, "Value", "czone")

#intersect stormlines with raster to append raster values
addMessage("*** Populating polylines with ms4 from raster ***")
PolylineRasterIntersect(conveyance, ms4, "Value", "ms4")

#intersect stormlines with raster to append raster values
addMessage("*** Populating polylines with ImpA from raster ***")
PolylineRasterIntersect(conveyance, ImpA, "Value", "ImpA")

#intersect stormlines with raster to append raster values
addMessage("*** Populating polylines with ROW from raster ***")
PolylineRasterIntersect(conveyance, ROW, "Value", "ROW")

#accumulate values from raster
addMessage("*** Populating polylines with ROW accumulation from raster ***")
AccumulateToNetwork(conveyance, nodes, catchments, flowdir, ROW_accum, 'ROW_accum', accumFactor=9.0)

